﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Collections.ObjectModel;

namespace Bonobo.Reader.UI
{
    public class BonoboItemCollection : ObservableCollection<BonoboItem>
    {
        public BonoboItemCollection()
        {         
            var filter = new BonoboItemFilter(0, false, 10, null);
            FillCollection(filter);
        } 

        public BonoboItemCollection(BonoboItemFilter filter)
        {
            FillCollection(filter);
        }

        private void FillCollection(BonoboItemFilter filter)
        {
            var providers = BonoboItemProviderLoader.GetInstance().Providers;
            var items = new List<BonoboItem>();

            foreach (var provider in providers)
            {
                items.AddRange(provider.GetItems(filter));
            }

            foreach (var item in items)
            {
                Add(item);
            }
        }
    }
}
